#include<iostream>
#include<string>
using namespace std;
int main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        string s;
        int sum=0;
        cin>>s;
        for(int j=0;j<s.size();j++){
            if(s[j]>='0'&&s[j]<='9'){
            sum++;
        }
        }
        cout<<sum<<endl;
    }
}